<?php
require_once PATH_SITE.'cn/royan/php/demos/ServerSetting.php';
require_once PATH_SITE.'cn/royan/php/utils/Logger.util.php';
require_once PATH_SITE.'cn/royan/php/controllers/commands/ReceiveDataCommand.command.php';
require_once PATH_SITE.'cn/royan/php/controllers/commands/StartSocketCommand.command.php';
require_once PATH_SITE.'cn/royan/php/controllers/commands/UserConnectCommand.command.php';
require_once PATH_SITE.'cn/royan/php/controllers/commands/DispatchDataCommand.command.php';
require_once PATH_SITE.'cn/royan/php/controllers/commands/DispatchEventCommand.command.php';
require_once PATH_SITE.'cn/royan/php/controllers/commands/UserDisconnectCommand.command.php';
require_once PATH_SITE.'cn/royan/php/controllers/commands/StartApplicationCommand.command.php';

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
require_once PATH_SITE.'org/puremvc/php/patterns/facade/Facade.php';
/**
 * Description of ApplicationFacade
 *
 * @author yanr
 */
class ApplicationFacade extends Facade
{
    //put your code here
    const START_APPLICATION			= "startApplication";
    const START_SOCKET_CONNECT                  = "startSocketConnect";
    const USER_START_CONNECT                    = "userStartConnect";
    const USER_END_CONNECT                      = "userEndConnect";
    const RECEIVE_CLIENT_DATA                   = "receiveClientData";
    const DISPATCH_CLIENT_DATA                  = "dispatchClientData";
    const DISPATCH_EVENT                        = "dispatchEvent";

    static public function getInstance()
    {
        if( parent::$instance == null ){
            parent::$instance = new ApplicationFacade();
        }
        return parent::$instance;
    }
    
    public function startUp( $config )
    {
        Logger::trace( "Load Config File:".$config );
        $this->sendNotification( ApplicationFacade::START_APPLICATION, $config );
    }
    
    protected function initializeController()
    {
        parent::initializeController();
        $this->registerCommand( ApplicationFacade::START_APPLICATION,       'StartApplicationCommand' );
        $this->registerCommand( ApplicationFacade::START_SOCKET_CONNECT,    'StartSocketCommand' );
        $this->registerCommand( ApplicationFacade::USER_START_CONNECT,      'UserConnectCommand' );
        $this->registerCommand( ApplicationFacade::USER_END_CONNECT,        'UserDisconnectCommand' );
        $this->registerCommand( ApplicationFacade::RECEIVE_CLIENT_DATA,     'ReceiveDataCommand' );
        $this->registerCommand( ApplicationFacade::DISPATCH_CLIENT_DATA,    'DispatchDataCommand' );
        $this->registerCommand( ApplicationFacade::DISPATCH_EVENT,          'DispatchEventCommand' );
    }
}

?>
